<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!-- 获取<p class='demo'>hello JavaScript</p>内部文案 -->
    <script>
        const tag = `<p class='demo'>hello JavaScript</p>`;
        // 匹配正则
        const reg = /^<.+?>(.+)<.+>$/
            //替换指定部分
        const str = tag.replace(reg, function(match, $1) {
            return $1
        })
        console.log(str);
    </script>
</body>

</html>